<?php
/**
 * @copyright meila.com
 * @author shaopu@
 * @name 
 * @param 
 *         $xxx = 作用
 * @static 
 *         XXX = 作用
 * 
 * 
 */
$dir = dirname(dirname(__FILE__));
include($dir.'/__queue_global.php');

class ml_mq_update_token extends MqClass{
    const QUEUE_NAME = ML_QUEUENAME_UPDATETOKEN;

    public function __construct($queue)
    {
        parent::__construct($queue);
    }
    
    public function run_job(){
        //接收的数据
        //uid  /server_id  /access_token
        $arr = $this->src_data;
        if(empty($arr['uid']) || empty($arr['server_id']) || empty($arr['access_token']) ){
            return false;
        }
        
        $o3rdSer = new ml_model_db3rdService();
        $rs=$o3rdSer->get3rdServiceUser($arr['uid'],$arr['server_id'],$data);
        if(!$rs){
            return false;
        }
        if($data['access_token'] == $arr['access_token'] ){
            return true;
        }
        
        $rs=$o3rdSer->updateAccessToken($arr['uid'],$arr['server_id'],$arr['access_token']);
        if(!$rs){
            return false;
        }
        return true;
    }

}
ml_run_queue_check(ml_mq_update_token::QUEUE_NAME);
$xblog_obj = new ml_mq_update_token(new McQueue(ml_mq_update_token::QUEUE_NAME));
$argv[1]   = __FILE__;
$xblog_obj->setArgv($argv[1]);
$xblog_obj->execute();
?>